<template>
  <view class="container">
    <view class="title flex-st">
      <view class="line"></view>
      <view class="t1">实名信息提交</view>
    </view>
    <u--form
      class="formBox"
      labelPosition="top"
      :model="form"
      :rules="rules"
      ref="form1"
      :labelStyle="{
        width: '127px',
        height: '24rpx',
        fontSize: ' 24rpx',
        fontFamily: 'Microsoft YaHei',
        fontWeight: '400',
        color: '#04030F',
      }"
    >
      <u-form-item label="真实姓名" prop="name">
        <u--input
          :customStyle="{ background: '#F4F4F4' }"
          v-model="form.name"
        ></u--input>
      </u-form-item>
      <u-form-item label="身份证号码" prop="code">
        <u--input
          :customStyle="{ background: '#F4F4F4' }"
          v-model="form.code"
        ></u--input>
      </u-form-item>
    </u--form>
    <view class="tips">
      <p>
        *为响应《互联网跟帖评论服务管理规定》和《国家新闻出版署
        关于防止未成年人沉迷网络游戏的通知》需要认证您的真实身
        份信息。您提供的真实身份信息将受到严格保护，仅用于判断
        您是否满足评论、发帖等服务的要求，以及是否满足下载、
        购买游戏的要求，不会用于其他用途，请您放心填写
      </p>
      <p>*请使用真实姓名及有效身份证号码进行实名信息提交</p>
      <p>*身份信息提交后不可进行修改</p>
      <p>*有意填写非本人身份信息者，被发现将对账号进行封禁处理</p>
      <p>*如有疑问，可联系官方客服</p>
    </view>
    <view class="btn">
      <u-button
        :disabled="false"
        :customStyle="{ width: '600rpx' }"
        color="#13B9C7"
        type="primary"
        
        text="提交"
		v-on:click="sub()"
      ></u-button>
    </view>
  </view>
</template>

<script>
	import {subIdcard} from  "@/api/api.js"
export default {	
	
  name: "form1",
  data() {
    return {
      form: {
        name: "",
        code: "",
      },
      rules: {
        name: {
          type: "string",
          required: true,
          message: "请填写真实姓名",
          trigger: ["blur", "change"],
        },
        code: {
          type: "string",
          required: true,
          len: 18,
          message: "请填写18位身份证号码",
          trigger: ["blur", "change"],
        },
      },
    };
  },
  onLoad(real_name,idcard) {
	  // uni.setStorageSync('real_name','');
	  // uni.setStorageSync('idcard','');
			real_name = uni.getStorageSync('real_name');
			idcard = uni.getStorageSync('idcard');
			if(real_name)
			{
				uni.redirectTo({
					url:'/pages/authentication/index'
				})
			}
  },
  methods: {
	  sub(){
		  var phone = uni.getStorageSync('phone');
		  // console.log(phone);
			subIdcard(this.form.name,this.form.code,phone).then(res=>{
				if(res.code==200){
					uni.setStorageSync('real_name',res.data.real_name);
					uni.setStorageSync('idcard',res.data.idcard);
					console.log(res)
					uni.showToast({
						title: res.msg,
						icon: 'success'
					})
					setTimeout(() => {
						uni.hideToast();
						uni.redirectTo({
							url: '/pages/authentication/index' // 传递参数 id，值为1					
						});
					},1500);
					
				}else{
					uni.showToast({
						title: res.msg,
						icon: 'error'
					})
					return
				}
			});	
	  }
  },
};
</script>
<style lang="scss" scoped>
.container {
  padding: 0 45rpx;
  height: 80vh;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  .title {
    width: 100%;
    margin-bottom: 50rpx;
    .line {
      margin-right: 14rpx;
      width: 6rpx;
      height: 34rpx;
      background: #13b9c7;
    }
    .t1 {
      font-size: 30rpx;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #04030f;
    }
  }
  .formBox {
    width: 100%;
  }
  .tips {
    font-size: 24rpx;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #858585;
    line-height: 36rpx;
    p:first-child {
      margin-bottom: 56rpx;
    }
    p:last-child {
      margin-bottom: 44rpx;
    }
  }
}
</style>
